/*
 * @Author: your name
 * @Date: 2020-10-16 16:23:56
 * @LastEditTime: 2020-10-30 16:11:17
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /Project/node/routes/users.js
 */
const express = require('express');
const router = express.Router();
const { body } = require('express-validator');
const service = require('../services/userService');


// 登录校验
const vaildator_login = [
    body('phone').isMobilePhone('zh-CN').withMessage('请输入11位有效手机号')
]

// 注册校验
const vaildator_register = [
    body('phone').isMobilePhone('zh-CN').withMessage('请输入11位有效手机号'),
    body('BusinessName').notEmpty().withMessage('请输入商家名称'),
    body('BusinessLocation').notEmpty().withMessage('请输入地址信息'),
    body('longitude').notEmpty().withMessage('无法获取经纬度'),
    body('latitude').notEmpty().withMessage('无法获取经纬度')    
]

// 用户登录路由
router.post('/onLogin',vaildator_login, service.onLogin);

// 商家注册
router.post('/registerBusiness',vaildator_register, service.registerBusiness);


module.exports = router;
